package d6_groupChat;

import com.sun.deploy.appcontext.AppContext;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class Server {
    public static List<Socket> onLineSockets = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        System.out.println("Server started......");
        ServerSocket serverSocket = new ServerSocket(4865);

        while (true) {
            Socket socket = serverSocket.accept();//接口接受连接
            onLineSockets.add(socket);
            System.out.println(socket.getRemoteSocketAddress()+"Client connected");
            //创建独立的线程来接收消息
            ServerReaderThread srt = new ServerReaderThread(socket);
            srt.start();
        }
    }
}
